<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Home\Controller;
use Think\Controller;
class WlController extends Controller {


	/*
	* 1(号码存在) 2(报名成功) 0(失败)
	*/	
	public function index(){
		header("Access-Control-Allow-Origin:*");
		/*星号表示所有的域都可以接受，*/
		header("Access-Control-Allow-Methods:GET,POST");
		$name = I('post.name');
		$tel = I('post.tel');
		if(!empty($name) && !empty($tel)){ 
			$wl = D(C('TABLE_WLINFO'));
			$res = $wl->where(array("w_tel"=>$tel))->find();
			if(!empty($res)&& $res!=null){ 
				$result = 1; //标示1:数据存在
			}else{ 
			   //$result = array('ret'=>2,'data'=>$res); //标示2: 成功
				$data['w_name'] = $name;
				$data['w_tel'] = $tel;
				$res = $wl->add($data);
			   if($res){
				 //报名成功
				  $result = 2;
				}else{
				 //报名失败
				  $result = 0;
				}
			}
		   echo $result;
		}

	}

	//数据显示
	public function telinfoshow(){
		$wl = D(C('TABLE_WLINFO'));
		$count = $wl->count();
		//每页显示条数
		$num = 15;
		$page = new \Think\Page($count,$num);
		$obj = pagestyle($page);
		$show = $obj->show();
		$res = $wl->order(array('id'=>'DESC'))->limit(limitbakstr($obj))->select();
		$this->assign('result',$res);
		$this->assign('page',$show);
		$this->display('Wl/index');
	}


}
?>